<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Repair Bonus Summary</title>
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>
<script type="text/javascript" src="/js/jquery.leanModal.min.js"></script>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<script language="javascript"> 
$(function() {
	$( "#display_date" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1,beforeShowDay: function(date){ return [date.getDay() == 1,""]}});
	
});
</script>

</head>
<body style="font-family:Arial, Helvetica, sans-serif; line-height:20px;">
<h2>Phone Stock Take</h2>
<form method = "post" action = "">
<?php if($this->errorflag != true){
	$stfDetail = new Model_DbTable_Roster_Stafflogindetail();
	$transRecord = new Model_DbTable_Pr_Transrecord();?>
Pick Up Other Date:<input type = "text" id = "display_date" name = "chooseDate" ></input>
<input type = "submit" name = "sub_date" value = "Choose Date"></input>
<?php $i = 1;$y = 1;?>

	<h2><?php echo $this->date." Confirm List"?></h2>
	<table border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>No.</th>
			<th>Job ID</th>
			<th>Customer Name</th>
			<th>Mobile</th>
			<th>Staff Charge</th>
			<th>Result</th>
			<th colspan = "2">Confirm</th>
		</tr>
		<?php foreach ($this->jobList as $k => $v){
				if($v['result'] == 3 && empty($v['confirm'])){
					$stf = $stfDetail->getDetail($v['charge_id']);
					?>
				<tr>
					<td><?php echo $i++;?></td>
					<td><?php echo $v['job_id'];?></td>
					<td><?php echo $v['customer'];?></td>
					<td><?php echo $v['model']?></td>
					<td><?php echo $stf['ni']?></td>
					<td><?php if($v['result'] == 1){echo 'In Store';}elseif($v['result'] == 2){echo 'Technician';}elseif($v['result'] == 3){echo 'Head Office';}
					elseif($v['result'] == 4){echo $v['other_reason'];}?></td>
					<td><input type = "checkbox" name = "confirm[<?php echo $v['id']?>]" checked></input></td>
					<td>Comment:<input type = "text" name = "reason[<?php echo $v['id']?>]" size = "8"></input></td>
				</tr>
		<?php 	}
			  }?>
	
	</table>
	
	<br/><br/>
		
	Input your password:<input type = "password" name = "password" ></input><br/><br/>
	<input type = "submit" name = "submit" value = "I checked all phone on hand"></input>
	<br/><br/>
	<h2><?php echo $this->date." Result"?></h2>
	<table border="1" cellspacing="1" cellpadding="5">
		<tr>
			<th>No.</th>
			<th>Job ID</th>
			<th>Customer Name</th>
			<th>Mobile</th>
			<th>Staff Charge</th>
			<th>Result</th>
			<th>Check Date</th>
		</tr>
		<?php foreach ($this->jobList as $k => $v){
				if(!empty($v['confirm']) || $v['result'] != 3){
						$stf = $stfDetail->getDetail($v['charge_id']);
					$reCheck = $transRecord->getLastTrack($v['job_id']);
					if($reCheck){
						$tec = $stfDetail->getDetail($reCheck['id_staff']);
					}?>
				<tr>
					<td><?php echo $y++;?></td>
					<td><?php echo $v['job_id'];?></td>
					<td><?php echo $v['customer'];?></td>
					<td><?php echo $v['model']?></td>
					<td><?php echo $stf['ni']?></td>
					<td><?php if($v['result'] == 1){echo 'In Store';}
					elseif($v['result'] == 2){echo 'Technician';if($tec){echo "(".$tec['ni'].")";}}
					elseif($v['result'] == 3 && empty($v['other_reason'])){echo 'Head Office';}
					elseif($v['result'] == 3 && !empty($v['other_reason'])){echo $v['other_reason'];}
					elseif($v['result'] == 4){echo $v['other_reason'];}?></td>
					<td><?php echo $v['check_date']?></td>
				</tr>
		<?php 	}
			  }?>
	
	</table>
	<br/><br/>
	

</form>
<?php }else{?>
<table width="500" border="0" cellspacing="0" cellpadding="10" align="left" style="border:#603 1px solid;">
  <tr>
    <td align="center" bgcolor="#FEDADD"><?=$this->errorMessage ?></td>
    <td><a href="javascript:history.go(-1)">Back to last page</a></td>
  </tr>
</table>
<?php }?>
</body>
</html>
